#include "rclcpp/rclcpp.hpp"

class PersonNode : public rclcpp::Node
{
private:
    std::string name_;
    int age_;
public:
    PersonNode(const std::string &node_name,const std::string &name,const int &age) : Node(node_name)
    {
        // this->name_ = name;
        // this->age_ = age;
        name_ = name;
        age_ = age;
    }

    void eat(const std::string &food)
    {
        RCLCPP_INFO(this->get_logger(),"I am %s , 今年 %d 岁, 爱吃 %s",name_.c_str(),age_,food.c_str());
    }
};

int main(int argc, char **argv)
{
    rclcpp::init(argc, argv);
    auto node = std::make_shared<PersonNode>("person_node","ros机器人",1);
    RCLCPP_INFO(node->get_logger(),"Hello World!");
    node->eat("苹果");
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}

